
##
## TODO remove
##
.deisotop=function(feature,rterror=1){
  count =1
  res <- matrix(0, nrow=dim(feature)[1],ncol=4)
  while(dim(tmp)[1]>0){
    work <- feature[1,]
    rt1 <- tmp$RT[1]-rterror
    rt2 <- tmp$RT[1]+rterror
    vol <- tmp$Volume[1]/30
    mz2 <- tmp$MZ[1]+3.2
    mz1 <- tmp$MZ[1]-1.1
    wx <- which( tmp$RT>rt1 & tmp$RT < rt2 & tmp$MZ >= mz1 & tmp$MZ < mz2 )
    test <- tmp[wx, ]
    
    
    tmp <- tmp[-wx,]
    
    1/mean(diff(test$MZ))
    charge <- round(1/median(diff(test$MZ)))
    x<- unlist(c(work,charge))
    res[count,]<-x 
    count = count + 1
  }
  res <- res[1:( count - 1 ),]
  colnames(res) <- c("RT","MZ","Volume","Charge")
  return(res)
}


coord <- getMZRTVol(con,idswath,rtrange=c(rtmin,rtmax),features=features)

